import UIKit

let a: Int = 9

let learniOS = {
    print("学习iOS")
}
learniOS()

let learn = {(lan: String) in
    print("学习\(lan)")
}
learn("iOS")

let learn1 = {(lan: String) -> String in
    "学习\(lan)"
}
let res = learn1("iOS")
print(res)

//作为另外一个函数的参数
func findWork(how: ()->Void) {
    print("准备找工作")
    how()
    print("找到工作了")
}
findWork(how: learniOS)



func findWork2(a: Int, how:(String) -> Void){
    print("准备找工作2")
    how("iOS")
    print("找到工作了2")
}

findWork2(a: a, how:learn)

findWork2(a: a) { (lan) in
    print("学习\(lan)")
}



//$0,$1
findWork2(a: a) {
    print("还是学习\($0)")
}

func findWork3() -> (String) -> Void {
    return { str in
        print("不要问，问就是在学习\(str)")
        
    }
}

let res2 = findWork3()

res2("iOS")



func findWork4() -> (String) -> Void {
    var counter = 1
    
    return {
        print("不要问，问就是在学习\($0)+\(counter)")
        counter += 1
    }
}

let res3 = findWork4()

res3("iOS")
res3("iOS")
res3("iOS")

